﻿using AnlianCommon.Common.Domains.BankCustomers;
using AnlianCommon.Common.DTO;
using AnlianCommon.Common.Infrastructure.IRepository;
using AnlianCommon.Enum;
using AutoMapper;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace SheepCommon.API.Vendors
{
    public class GPpriceSearchHander : IRequestHandler<GPpriceSearchCommand, ResultPage<GPprice>>
    {
        private readonly IBaseRepository<GPprice> gpPriceRepository;
        private readonly IMapper mapper;

        public GPpriceSearchHander(IBaseRepository<GPprice> gpPriceRepository, IMapper mapper)
        {
            this.gpPriceRepository = gpPriceRepository;
            this.mapper = mapper;
        }

        /// <summary>
        /// 商品价格显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ResultPage<GPprice>> Handle(GPpriceSearchCommand request, CancellationToken cancellationToken)
        {
            var result = new ResultPage<GPprice>() { Code = (int)CommonErrorCode.Search};
            try
            {
                var gpprice = await(await gpPriceRepository.GetAll()).ToListAsync();

            }
            catch (Exception ex)
            {
                throw;
            }
            return result;
        }
    }
}
